/**
  @file sm4.h
  @brief this file contains the declarations and documentation for SM4 algorithm

  Function Declarations:
  - sm4_encrypt(): Encrypts a plaintext using the SM4 algorithm with the provided key.
  - sm4_decrypt(): Decrypts a ciphertext using the SM4 algorithm with the provided key.
**/

#include "common.h"

#ifndef SM_SM4_H
#define SM_SM4_H

/**
 * @brief Encrypts a plaintext using the SM4 algorithm with the provided key.
 * @param ciphertext The output buffer to store the encrypted ciphertext.
 * @param plaintext The input buffer containing the plaintext to be encrypted.
 * @param key The key used for encryption.
 */
void sm4_encrypt(u8 *ciphertext, const u8 *plaintext, const u8 *key);


/**
 * @brief Decrypts a ciphertext using the SM4 algorithm with the provided key.
 * @param plaintext The output buffer to store the decrypted plaintext.
 * @param ciphertext The input buffer containing the ciphertext to be decrypted.
 * @param key The key used for decryption.
 */
void sm4_decrypt(u8 *plaintext, const u8 *ciphertext, const u8 *key);


/**
 * @brief Encrypts a plaintext using the SM4 algorithm with the provided key in ECB mode.
 * @param ctext The output buffer to store the encrypted ciphertext.
 * @param ptext The input buffer containing the plaintext to be encrypted.
 * @param key The key used for encryption.
 */
void sm4_ecb_encrypt(u8 *ctext, u32 pbitlen, const u8 *ptext, const u8 *key);


/**
 * @brief Decrypts a ciphertext using the SM4 algorithm with the provided key in ECB mode.
 * @param ptext The output buffer to store the decrypted plaintext.
 * @param ctext The input buffer containing the ciphertext to be decrypted.
 * @param key The key used for decryption.
 */
void sm4_ecb_decrypt(u8 *ptext, u32 cbitlen, const u8 *ctext, const u8 *key);


#endif //SM_SM4_H
